<template>
    <div>
      <el-input v-model="queryInfo.name" placeholder="请输入内容"></el-input>
      <el-button type="primary" @click="getAllProductByName">查询</el-button>
      <el-table :data="ProductList" stripe style="width: 100%">
        <el-table-column prop="pName" label="名称" width="180"></el-table-column>
        <el-table-column prop="model" label="规格" width="180"></el-table-column>
        <el-table-column prop="stock" label="库存" width="180"></el-table-column>
        <el-table-column prop="unit" label="单位"></el-table-column>
      </el-table>
    </div>
</template>

<script>
export default {
  name: 'ProductStocks',
  data () {
    return {
      ProductList: [],
      queryInfo: {
        name: ''
      }
    }
  },
  mounted () {
    this.getAllProduct()
  },
  methods: {
    async getAllProduct () {
      const { data: res } = await this.$http.get('biz/pro/getAllProduct')
      if (res.code !== 200) {
        return this.$message.error(res.msg)
      }
      this.ProductList = res.data
    },
    async getAllProductByName () {
      const { data: res } = await this.$http.get('biz/pro/getAllProductByName', { params: this.queryInfo })
      if (res.code !== 200) {
        return this.$message.error(res.msg)
      }
      this.ProductList = res.data
    }
  }
}
</script>

<style scoped>

</style>
